Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
The is-buffer npm package is a simple utility module used to determine if an object is a Node.js Buffer. This package is particularly useful when working with modules that are designed to work both in the browser and Node.js, where the Buffer class is not available in the global scope in the browser.
Buffer Detection
This feature allows you to check if a given object is an instance of a Buffer. The function returns true if the object is a Buffer, and false otherwise.
var isBuffer = require('is-buffer');
var buffer = new Buffer('This is a buffer');
var notBuffer = {};
console.log(isBuffer(buffer)); // true
console.log(isBuffer(notBuffer)); // false
The 'buffer' package is a Node.js Buffer implementation for the browser. It's more complex than is-buffer as it aims to provide the entire Buffer API in environments that do not have it natively. Unlike is-buffer, which only checks if an object is a Buffer, the 'buffer' package allows you to create and manipulate Buffer objects in the browser.
Buffer
(including the browserify Buffer)Buffer.isBuffer
?This module lets you check if an object is a Buffer
without using Buffer.isBuffer
(which includes the whole buffer module in browserify).
It's future-proof and works in node too!
npm install is-buffer
var isBuffer = require('is-buffer')
isBuffer(new Buffer(4)) // true
isBuffer(undefined) // false
isBuffer(null) // false
isBuffer('') // false
isBuffer(true) // false
isBuffer(false) // false
isBuffer(0) // false
isBuffer(1) // false
isBuffer(1.0) // false
isBuffer('string') // false
isBuffer({}) // false
isBuffer(function foo () {}) // false
MIT. Copyright (C) Feross Aboukhadijeh.
FAQs
Determine if an object is a Buffer
The npm package is-buffer receives a total of 34,607,174 weekly downloads. As such, is-buffer popularity was classified as popular.
We found that is-buffer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.